﻿@{ Ajax.Dna().Widget()
       .Content(widget =>
       {
           var context = WebSiteContext.Current;
           Ajax.Dna().Menu(widget.GenerateFieldID("_MetaMenu"))
                .Options(options =>
                {
                    options.MenuType = MenuTypes.Vertical;
                })
                .Items(items =>
                {
                    var web = context.Web;
                    Category defaultCategory = ViewBag.TopCategory;
                    if (Context.Request.IsAuthenticated)
                    {
                        //Owner actions
                        if (Context.User.IsWebOwner())
                        {
                            items.Add(Html.Global("publishing", "WritePost"), Url.Action("Create", "Article", new
                            {
                                Area = "Publishing",
                                website = web.Name,
                                categoryID = string.IsNullOrEmpty(Request.QueryString["categoryID"]) ? defaultCategory.ID : int.Parse(Request.QueryString["categoryID"])
                            }), Url.Content("~/Content/Images/add.png"));

                            items.Add(Html.Global("RES_CREATEPAGE"), Url.Action("Create", "DynamicUI", new { Area = "" }),
                                       Url.Content("~/Content/Images/add_page.png"));

                            //items.Add(Html.Global("RES_MYCONSOLE"), Url.RouteUrl("dna_mysite", new { website = Context.Profile.UserName, action = "Profile", controller = "Account", Area = "" }),
                            //           Url.Content("~/Content/Images/my_console.gif"));

                            //if (WebHost.EnablePersonalWeb)
                            //    items.Add(Html.Global("RES_MYCONSOLE"), Url.RouteUrl("dna_mysite", new { website = Context.Profile.UserName, action = "Index", controller = "Sys", Area = "" })
                            //               , Url.Content("~/Content/Images/my_console.gif"));
                            //else
                            items.Add(Html.Global("RES_MYCONSOLE"), Url.Action("Profile", "Account", new { Area = "", website = web.Name }), Url.Content("~/Content/Images/my_console.gif"));
                        }
                    }
                    else
                    {
                        items.Add(Html.Global("RES_LOGIN"), Url.Action("Login", "Account", new { Area = "" }),
                             Url.Content("~/Content/Images/icon_unlock.gif"));

                        if (context.RootWeb.EnableUserRegistration)
                            items.Add(Html.Global("RES_REGISTER"), Url.Action("Register", "Account", new { Area = "" }),
                               Url.Content("~/Content/Images/icon_unlock.gif"));
                    }

                    items.Add(Html.Global("publishing", "AddToFavorite"), "javascript:uiHelper.addBookMark('" + web.Title + "');void(0);",
                        Url.Content("~/Content/Images/fav.gif"));
                    items.Add(Html.Global("publishing", "BackToTopSite"), Url.Content("~/"),
                        Url.Content("~/Content/Images/back.png"));
                })
                    .Render();
       })
       .Render();
}
